﻿using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Web;

namespace NWebMock
{
    public class HttpCookieCollectionWrapper : IHttpCookieCollection
    {
        #region Constructors

        public HttpCookieCollectionWrapper(HttpCookieCollection cookies)
        {
            if (cookies == null)
            {
                throw new ArgumentNullException("cookies");
            }

            this.innerCookies = cookies;
        }

        #endregion

        #region Fields

        private HttpCookieCollection innerCookies = null;

        #endregion

        #region Properties

        public string[] AllKeys { get { return this.innerCookies.AllKeys; } }

        public int Count { get { return this.innerCookies.Count; } }

        public HttpCookie this[int index] { get { return this.innerCookies[index]; } }

        public HttpCookie this[string name] { get { return this.innerCookies[name]; } }

        public ICollection Keys { get { return this.innerCookies.Keys; } }

        #endregion

        #region Methods

        public void Add(HttpCookie cookie)
        {
            this.innerCookies.Add(cookie);
        }

        public void Clear()
        {
            this.innerCookies.Clear();
        }

        public void CopyTo(Array dest, int index)
        {
            this.innerCookies.CopyTo(dest, index);
        }

        public HttpCookie Get(int index)
        {
            return this.innerCookies.Get(index);
        }

        public HttpCookie Get(string name)
        {
            return this.innerCookies.Get(name);
        }

        public IEnumerator GetEnumerator()
        {
            return this.innerCookies.GetEnumerator();
        }

        public string GetKey(int index)
        {
            return this.innerCookies.GetKey(index);
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            this.innerCookies.GetObjectData(info, context);
        }

        public void OnDeserialization(object sender)
        {
            this.innerCookies.OnDeserialization(sender);
        }

        public void Remove(string name)
        {
            this.innerCookies.Remove(name);
        }

        public void Set(HttpCookie cookie)
        {
            this.innerCookies.Set(cookie);
        }

        #endregion

        #region ICollection Members

        void ICollection.CopyTo(Array dest, int index)
        {
            this.innerCookies.CopyTo(dest, index);
        }

        bool ICollection.IsSynchronized { get { return ((ICollection)this.innerCookies).IsSynchronized; } }

        object ICollection.SyncRoot { get { return ((ICollection)this.innerCookies).SyncRoot; } }

        #endregion
    }
}
